import {request} from '@umijs/max';
import * as API from "@/services";


/** 素材组 分页检索请求 */
export async function queryMaterialGroups(params: API.MaterialGroupPageQueryParams): Promise<API.RespPageResult<API.MaterialGroup>> {
  return request('/api/v1/material-group', {
    params,
  });
}

/** 素材组 详情请求 */
export async function queryMaterialGroup(bizId: API.EntityId): Promise<API.RespResult<API.MaterialGroup>> {
  return request(`/api/v1/material-group/${bizId}`);
}

/** 素材组 创建请求 */
export async function createMaterialGroup(entity: API.MaterialGroup_Create): Promise<API.RespResult<any>> {
  return request(`/api/v1/material-group`, {
    method: 'POST',
    data: entity,
  });
}

/** 素材组 修改请求 */
export async function modifyMaterialGroup(entity: API.MaterialGroup_Modify): Promise<API.RespResult<any>> {
  return request(`/api/v1/material-group/${entity.id}`, {
    method: 'PUT',
    data: entity,
  });
}

/** 素材组 修改(部分)请求 */
export async function patchMaterialGroup(entity: API.MaterialGroup_Patch): Promise<API.RespResult<any>> {
  return request(`/api/v1/material-group/${entity.id}`, {
    method: 'PATCH',
    data: entity,
  });
}

/** 素材组 删除请求 */
export async function deleteMaterialGroup(bizId: API.EntityId): Promise<API.RespResult<any>> {
  return request(`/api/v1/material-group/${bizId}`, {
    method: 'DELETE',
  });
}

/** 素材组 批量删除请求 */
export async function deleteMaterialGroups(bizIds: API.EntityId[]): Promise<API.RespResult<any>> {
  return request(`/api/v1/material-group`, {
    method: 'DELETE',
    data: {
      ids: bizIds,
    },
  });
}


/** 素材组 详情请求 */
export async function queryMaterialGroupTree(params: API.MaterialGroupTreeQueryParams): Promise<API.RespListResult<API.MaterialGroup_TreeNode>> {
  return request('/api/v1/material-group/tree', {
    params,
  });
}

/** 素材组 移动位置(seq) **/
export async function moveMaterialGroup(dto: API.MaterialGroup_Move): Promise<API.RespResult<any>> {
  return request(`/api/v1/material-group/move-seq`, {
    method: 'PUT',
    data: dto,
  });
}

